package chapter03

/**
 * @program lu-scala01
 * @description: 特征-自身类型
 * @author: zhanglu
 * @create: 2022-03-27 19:13:00
 */
object C16_TraitSelfType {

  def main(args: Array[String]): Unit = {
    val user = new RegisterUser("lu", "111111")
    user.insert()
  }

}

class User16(val name: String, val pwd: String){

}

trait UserDao{
  //类似于注入了一个User16类（依赖注入的感觉）
  _: User16 =>

  def insert(): Unit = {
    println(s"insert into db: ${this.name}")
  }
}

//定义注册用户类
class RegisterUser(name: String, pwd: String) extends User16(name, pwd) with UserDao
